package com.goldcn.user.service;

import com.goldcn.common.util.IdGen;
import com.goldcn.interceptor.SystemContext;
import com.goldcn.user.dao.LogisticsMapper;
import com.goldcn.user.model.Logistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by 1111 on 2016/11/19.
 */
@Service
@Transactional
public class LogisticsService {
    @Autowired
    LogisticsMapper logisticsMapper;

    public Long addLogistics(Logistics logistics){
        logistics.setId(IdGen.get().nextId());
        logistics.setUrl(logistics.getUrl());
        logistics.setCompanyID(SystemContext.getCompanyID());
        logisticsMapper.insertSelective(logistics);
        return logistics.getId();
    }

    public int updateLogistics(Logistics logistics){
        return logisticsMapper.updateByPrimaryKeySelective(logistics);
    }

    public int deleteLogistics(Long id){
        return logisticsMapper.deleteByPrimaryKey(id);
    }

    public Logistics selectByID(Long id){
        return logisticsMapper.selectByPrimaryKey(id);
    }

    public List<Logistics> selectAll(){
        return logisticsMapper.selectAll(SystemContext.getCompanyID());
    }
}
